package cn.com.hatech.blog.module.admin.comment.controller;

import cn.com.hatech.blog.common.controller.BaseController;
import cn.com.hatech.blog.module.admin.comment.entity.Comment;
import cn.com.hatech.blog.module.admin.comment.service.ICommentService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;

/**
 * @projectName: hatech-blog
 * @package: cn.com.hatech.blog.module.admin.controller
 * @className: CommentController
 * @author: xuruikai
 * @description: 评论管理控制器
 * @date: 2020/1/11 14:27
 * @version: 1.0
 */
@Controller
@RequestMapping("admin/comments")
@Slf4j
public class CommentPageController extends BaseController {

    @Autowired
    private ICommentService commentsService;

    /**
     * 评论列表
     *
     * @param page
     * @param limit
     * @param request
     * @return
     */
    @GetMapping(value = "")
    public String index(@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "limit", defaultValue = "15") int limit, HttpServletRequest request) {
        IPage<Comment> commentsPaginator = commentsService.selectPage(page, limit);
        request.setAttribute("comments", commentsPaginator);
        return "admin/comment/comment_list";
    }

}
